package com.zhentao.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    //存响应码 20000
    private Integer code;
    //存提示信息
    private String massage;
    //向前端页面送的数据
    private Object obj;
    //工具方法
    //正常响应
    public static Result Ok(){
        Result result = new Result();
        result.setCode(20000);
        result.setMassage("操作成功");
        return  result;
    }
    public static Result Ok(String massage){
        Result result = new Result();
        result.setCode(20000);
        result.setMassage(massage);
        return  result;
    }
    public static Result Ok(String massage,Object obj){
        Result result = new Result();
        result.setCode(20000);
        result.setMassage(massage);
        result.setObj(obj);
        return  result;
    }
    //不正常响应
    public static Result ERROR(){
        Result result = new Result();
        result.setCode(40000);
        result.setMassage("操作失败");
        return result;
    }
    public static Result ERROR(String massage){
        Result result = new Result();
        result.setCode(40000);
        result.setMassage("操作失败");
        result.setMassage(massage);
        return result;
    }
    public static Result ERROR(String massage,Object obj){
        Result result = new Result();
        result.setCode(40000);
        result.setMassage("操作失败");
        result.setMassage(massage);
        result.setObj(obj);
        return result;
    }
    public static Result ERROR(Integer code,String message,Object obj){
        Result result = new Result();
        result.setCode(code);
        result.setMassage(message);
        result.setObj(obj);
        return result;
    }
}
